package com.hspedu.homework;

import java.util.ArrayList;

/**
 * @author LiuJinTao
 * @className HomeWork01
 * @date 2024/06/14 10:33
 * @description TODO
 */
public class HomeWork01 {
    public static void main(String[] args) {
        New New1 = new New("新冠确诊病例超千万，数百万印度教信徒赴恒河“圣浴”引民众担忧");
        New New2 = new New("男子突然想起两个月前钓的鱼还在网兜里，捞起一看赶紧放生");
        ArrayList list = new ArrayList();
        list.add(New1);
        list.add(New2);
        for (int i = list.size() - 1; i >= 0 ; i--) {
            New aNew = (New) list.get(i);
            String title = aNew.getTitle();
            if (title.length() > 15) {
                aNew.setTitle(title.substring(0, 15) + "···");
            }

            System.out.println(list.get(i));
        }

    }
}

class New {
    private String title;
    private String content;

    @Override
    public String toString() {
        return "New{" +
                "title='" + title + '\'' +
                '}';
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public New(String title) {
        this.title = title;
    }
}